import requests


class IhrmEmpApi():
    @classmethod
    def add_emp(cls, header, data):
        resp = requests.post(url="http://127.0.0.1:9002/sys/user",
                             headers=header,
                             json=data)
        return resp

    @classmethod
    def query_emp(cls, emp_id, header):
        resp = requests.get(url="http://127.0.0.1:9002/sys/user/"+emp_id,
                            headers=header)
        return resp
    @classmethod
    def modify_emp(cls, emp_id, data):
        resp = requests.get(url="http://127.0.0.1:9002/sys/user/"+emp_id,
                            headers=header, json=data)
        return resp

    @classmethod
    def delete_emp(cls, emp_id, header):
         resp = requests.get(url="http://127.0.0.1:9002/sys/user/"+emp_id,
                                headers=header)
         return resp


if __name__ == '__main__':
    header = headers={"Authorization": "96083385-e2ad-453a-bc1f-78de0c1e93d4"}
    data = {"username": "刘辰", "mobile": "17331202745", "workNumber": "6667"}

    # resp = IhrmEmpApi.add_emp(header, data)
    # print("添加员工响应结果：", resp.json())

    emp_id = "1912857877296799744"
    resp = IhrmEmpApi.query_emp(emp_id, header)
    print("查询员工响应结果：", resp.json())

    data1 = {"username": "王辰"}
    resp1 = IhrmEmpApi.modify_emp(emp_id, header)
    print("修改员工响应结果:", resp1.json())

    resp2 = IhrmEmpApi.delete_emp(emp_id, header)
    print("删除员工结果：", resp2.json())
